package com.hns.can.base.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.hns.can.base.entity.SysAuthrityButtonEntity;
import com.hns.can.base.entity.SysRoleEntity;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;

/**
 * 按钮权限service
 * @author:Fisher
 * @email:zhuangcaijin@126.com
 * @version Revision 2.0.0
 */
@Service
public class SysAuthorityButtonService extends CommonService {
    
    /**
     * 获取按钮权限
     * @param roleIdList
     * @return
     * @author:Fisher
     * @email:zhuangcaijin@126.com
     */
    @SuppressWarnings("unchecked")
    public List<String> getAuthorityBtnResource(List<SysRoleEntity> roleIdList){
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("roleIdList", roleIdList);
        List<SysAuthrityButtonEntity> list = PubUtil.convertListMapToObject(this.sqlMapDao.selectList("sysAuthorityButton.getAuthorityBtnResource",map), SysAuthrityButtonEntity.class);
        List<String> organIdlist = new ArrayList<String>();
        if(PubUtil.isNotEmpty(list)){
            for(SysAuthrityButtonEntity entity : list){
                organIdlist.add(entity.getButtonId());
            }
        }
        return organIdlist;
    }
}
